<template>
  <!--基本信息  -->
  <div style="height:590px">
    <FormPanel
      ref="formPanel"
      :list="initForm"
      :cols="2"
      :formType="value.type"
      :labelWidth="110"
      :isSubmitBtn="false"
      @formChange="formChangeHandle"
    />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      formValue: {}
    };
  },
  mounted() {
    console.log(this.value); //获取到行id 、类型（新增、详情）
    //请求接口进行赋值，自己写吧
  },
  methods: {
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'INPUT',
          label: '方案编号',
          fieldName: 'field1',
          disabled: true,
          initialValue: '系统自动生成'
        },
        {
          type: 'SELECT',
          label: '方案状态',
          fieldName: 'field2',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008'),
          disabled: true
        },
        {
          type: 'SELECT',
          label: '方案下发渠道',
          fieldName: 'field3',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008'),
          disabled: true
        },
        {
          type: 'RANGE_DATE',
          label: '活动周期',
          fieldName: 'field21',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: ['2019-08-12', '2019-09-18'],
          placeholder: '请选择',
          style:{width:'100%'},
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },

        {
          type: 'SELECT',
          label: '是否全网下发',
          fieldName: 'field5',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008')
        },
        {
          type: 'TEXT_AREA',
          label: '方案名称',
          fieldName: 'field41',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [{ required: true, message: '错误提示信息', trigger: 'blur' }] //验证
        },
        {
          type: 'TEXT_AREA',
          label: '方案描述',
          fieldName: 'field10',
          rows: 3,
          initialValue: '',
          placeholder: '请输入',
          rules: [{ required: true, message: '错误提示信息', trigger: 'blur' }] //验证
        },
        {
          type: 'UPLOAD_IMG',
          label: '附件',
          fieldName: 'UPLOAD_IMG',
          upload: {
            actionUrl: '', //上传的地址
            fixedSize: [300, 500], //剪裁尺寸
            isCalcHeight: false,
            limit: 1 //上传数量
          },
          initialValue: '',
          disabled: false
        }
      ];
    },
    formChangeHandle(val) {
      this.formValue = val;
    }
  }
};
</script>